﻿using System.Windows.Forms;

namespace DL.PhotoCollage.Wpf.Presentation
{
    public abstract class SetupPresenterBase
    {
        protected SetupPresenterBase(ControllerBase controller)
        {
            this.Controller = controller;
        }

        public ControllerBase Controller { get; private set; }

        public void RequestDirectoryFromUser()
        {
            var dialog = new FolderBrowserDialog
            {
                Description = "Select a folder",
                ShowNewFolderButton = false
            };

            var result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                string path = dialog.SelectedPath;
                if (!string.IsNullOrEmpty(path))
                {
                    this.Controller.Configuration.Directory = path;
                }
            }
            else if (result != DialogResult.Cancel)
            {
                this.Controller.Configuration.Directory = string.Empty;    
            }
        }
    }
}
